<template>
  <div>
    user
  </div>
</template>

<script>
export default {
  name: "user",
  mounted() {
    this.setCookie('token', '1654565656', -1)
  },
  methods: {
    // https://blog.csdn.net/weixin_42220039/article/details/82220312?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.channel_param
    setCookie(c_name, value, expiredays) {
      var exdate = new Date();
      exdate.setDate(exdate.getDate() + expiredays);
      let path = '/';
// document.cookie = c_name + “=” + encodeURIComponent(value)+’;expires’ +exdate.toGMTString()+’;path=’+path+’;domain=’+domain; 设置成功后不在登陆
      document.cookie = c_name + "=" +encodeURIComponent(value) + ';expires' +exdate.toGMTString() + ';path ='+path;
    },
    getCookie(cname) {
      var name = cname + ''
      var ca = document.cookie.split(';');
      for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1);
        if (c.indexOf(name) != -1) return c.substring(name.length, c.length);
      }
      return "";
    },

    delCookie (name) {
      var exp = new Date();
      exp.setTime(exp.getTime() - 1);
      var cval = getCookie(name);
      if (cval != null)
        document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
    }
  }
}

</script>

<style scoped>

</style>
